#ifndef SLS_TABLE_H
#define SLS_TABLE_H

#include "ns3/timer.h"
#include "ns3/vector.h"
#include "ns3/ipv4.h"
#include <map>

namespace ns3{

/*********************************************************************************************************
 *       CLASS MAP ENTRY           :: Representa cada entrada da tabela ::
 ********************************************************************************************************/

class MapEntry{

public:

	MapEntry(Vector position, Time time, bool researchFlag, uint8_t numSeq);
	void SetPosition(Vector position) { m_position = position; }
	void SetSpeed(int speed) { m_speed = speed; }
	Vector GetPosition() { return m_position; }
	int GetSpeed() { return m_speed; }
	Time GetTime() { return m_time; }
	bool GetResearchFlag() { return m_researchFlag; }
	int GetSeqNumber(){ return m_seqNumber;}


private:
	Vector m_position;
	int m_speed; //When m_researchFlag true this is the time when the research starts
	Time m_time; //When m_researchFlag true this is the time when the research starts
	bool m_researchFlag;
	uint8_t m_seqNumber;

};

/********************************************************************************************************
 *       CLASS POSITIONTABLE          :: Tabela ::
 ********************************************************************************************************/

class PositionTable{
public:

	PositionTable(Time Lifetime) : m_entryLifeTime (m_entryLifeTime) {}

	Time GetEntryUpdateTime(Ipv4Address id);

	Vector GetPosition(Ipv4Address id);
	void SetPosition(Ipv4Address id, Vector position);
	void SetSpeed(Ipv4Address id,int speed);
	Time GetSpeed(Ipv4Address id);


	void AddEntry(Ipv4Address id, Vector position, Time time, bool flag, uint8_t seq);
	void DeleteEntry(Ipv4Address id);
	MapEntry GetEntry(Ipv4Address id);
	void PrintEntry();

	void Purge();
	void Clear();

private:
	Time m_entryLifeTime;
	std::map<Ipv4Address, MapEntry> m_table;

}; 
} 
#endif /* SLS_TABLE_H */

